home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / other / pmdev / e / modules / libraries / popupmenu.e next >
Encoding:
Text File  |  2000-02-28  |  13.1 KB  |  271 lines

  1. /* -- ----------------------------------------------------------------- -- *
  2.  * -- Program.....: popupmenu.e                                         -- *
  3.  * -- Author......: Daniel Kasmeroglu <raptor@cs.tu-berlin.de>          -- *
  4.  * -- Description.: Include for popupmenu.library for Amiga-E           -- *
  5.  * -- Version.....: 9.00 (02.12.99)                                     -- *
  6.  * -- ----------------------------------------------------------------- -- */
  7.  
  8. /* -- ----------------------------------------------------------------- -- *
  9.  * --                              Options                              -- *
  10.  * -- ----------------------------------------------------------------- -- */
  11.  
  12. OPT PREPROCESS       -> enable preprocessor
  13. OPT MODULE           -> generate module
  14. OPT EXPORT           -> export all
  15.  
  16.  
  17. /* -- ----------------------------------------------------------------- -- *
  18.  * --                              Modules                              -- *
  19.  * -- ----------------------------------------------------------------- -- */
  20.  
  21. ->»» LIST OF MODULES
  22. MODULE 'utility/tagitem'     ,
  23.        'utility/hooks'       ,
  24.        'exec/libraries'      ,
  25.        'intuition/intuition'
  26.  
  27. ->»»>
  28.  
  29.  
  30. /* -- ----------------------------------------------------------------- -- *
  31.  * --                              Macros                               -- *
  32.  * -- ----------------------------------------------------------------- -- */
  33.  
  34. ->»» LIST OF MACROS
  35.  
  36. #define POPUPMENU_VERSION       9
  37. #define POPUPMENU_NAME          "popupmenu.library"
  38.  
  39. #define PMStartMenu     Pm_MenuA( [ PM_DUMMY, 0
  40.  
  41. #define PMMenu(t)       Pm_MenuA( [ PM_ITEM, Pm_ItemA( [ PM_HIDDEN, TRUE, TAG_END ] ),\
  42.                         PM_ITEM, Pm_ItemA( [ PM_TITLE, t, PM_NOSELECT, TRUE, PM_SHINEPEN, TRUE, PM_SHADOWED, TRUE, PM_CENTER, TRUE, TAG_END ] ),\
  43.                         PM_ITEM, Pm_ItemA( [ PM_WIDETITLEBAR, TRUE, TAG_END ] )
  44.  
  45. #define PMMenuID(t)     Pm_MenuA( [ PM_ITEM, Pm_ItemA( [ PM_HIDDEN, TRUE, TAG_END ] ),\
  46.                         PM_ITEM, Pm_ItemA( [ PM_TITLEID, t, PM_NOSELECT, TRUE, PM_SHINEPEN, TRUE, PM_SHADOWED, TRUE, PM_CENTER, TRUE, TAG_END ] ),\
  47.                         PM_ITEM, Pm_ItemA( [ PM_WIDETITLEBAR, TRUE, TAG_END ] )
  48.  
  49. #define PMSubMenu(t)    PM_SUB, Pm_MenuA( [ PM_ITEM, Pm_ItemA( [ PM_TITLE, t, PM_NOSELECT, TRUE, PM_SHINEPEN, TRUE, TAG_END ] ),\
  50.                         PM_ITEM, Pm_ItemA( [ PM_WIDETITLEBAR, TRUE, TAG_END ] )
  51.  
  52. #define PMSimpleSub     PM_SUB, Pm_MenuA( [ PM_DUMMY, 0
  53.  
  54. #define PMItem(t)       PM_ITEM, Pm_ItemA( [ PM_TITLE, t
  55.  
  56. #define PMItemID(t)     PM_ITEM, Pm_ItemA( [ PM_TITLEID, t
  57.  
  58. #define PMInfo(t)       PM_ITEM, Pm_ItemA( [ PM_TITLE, t, PM_NOSELECT, TRUE, PM_SHINEPEN, TRUE
  59.  
  60. #define PMColBox(c)     PM_ITEM, Pm_ItemA( [ PM_COLOURBOX, c
  61.  
  62. #define PMBar           PM_ITEM, Pm_ItemA( [ PM_TITLEBAR, TRUE
  63.  
  64. -> For compatibility with old sources - DO NOT USE 
  65. -> please replace following macros by "PMBar" if you have used
  66. -> previous versions of "popupmenu.library"
  67. ->
  68. -> PMTitleBar, PMNarrowBar, PMNarrowTitleBar
  69. ->
  70.  
  71. #define PMMenuTitle(t)  PM_ITEM, Pm_ItemA( [ PM_TITLE, t, PM_NOSELECT, TRUE, PM_SHINEPEN, TRUE, PM_SHADOWED, TRUE, PM_CENTER, TRUE, TAG_END ] ),\
  72.                         PM_ITEM, Pm_ItemA( [ PM_WIDETITLEBAR, TRUE, TAG_END ] )
  73.  
  74. #define PMHoriz         PM_ITEM, Pm_ItemA( [ PM_NOSELECT, TRUE, PM_LAYOUTMODE, PML_HORIZONTAL
  75.  
  76. #define PMVert          PM_ITEM, Pm_ItemA( [ PM_NOSELECT, TRUE, PM_LAYOUTMODE, PML_VERTICAL
  77.  
  78. #define PMMembers       PM_MEMBERS, Pm_MenuA( [ PM_DUMMY, NIL
  79.  
  80. #define PMExcl(list)    PM_EXCLUDE, Pm_MakeIDListA(list)
  81. #define ExID(id)        PM_EXCLUDEID, id
  82. #define InID(id)        PM_INCLUDEID, id
  83. #define RefID(id)       PM_REFLECTID, id
  84. #define InvID(id)       PM_INVERSEID, id
  85.  
  86. #define PMCheckItem(t,id)   PM_ITEM, Pm_ItemA( [ PM_TITLE, t, PM_ID, id, PM_CHECKIT, TRUE
  87.  
  88. #define PMEnd           TAG_END ] )
  89. #define End             TAG_END ] )
  90.  
  91. ->»»>
  92.  
  93.  
  94. /* -- ----------------------------------------------------------------- -- *
  95.  * --                             Constants                             -- *
  96.  * -- ----------------------------------------------------------------- -- */
  97.  
  98. ->»» LIST OF CONSTANTS
  99.  
  100. -> Tags passed to Pm_OpenPopupMenuA and Pm_FilterIMsgA
  101.  
  102. CONST PM_MENU           = TAG_USER + 004 , -> (PTR TO popupmenu) Pointer to menulist initialized by MakeMenu()
  103.       PM_TOP            = TAG_USER + 012 , -> Top (Y) position
  104.       PM_LEFT           = TAG_USER + 013 , -> Left (X) position
  105.       PM_CODE           = TAG_USER + 014 , -> Read the documentation.
  106.       PM_RIGHT          = TAG_USER + 015 ,
  107.       PM_BOTTOM         = TAG_USER + 016 ,
  108.       PM_MINWIDTH       = TAG_USER + 017 ,
  109.       PM_MINHEIGHT      = TAG_USER + 018 ,
  110.       PM_FORCEFONT      = TAG_USER + 019 ,
  111.       PM_PULLDOWN       = TAG_USER + 090 , -> Make the menu a pulldown menu.
  112.       PM_MENUHANDLER    = TAG_USER + 091 , -> (PTR TO hook) Hook that is called for each selected item, after the
  113.                                            -> menu has been closed. This tag turns on MultiSelect.
  114.       PM_AUTOPULLDOWN   = TAG_USER + 092 , -> Make an automatic pulldown menu. (PM_FilterIMsg only)
  115.       PM_LOCALEHOOK     = TAG_USER + 093 , -> Locale "GetString()" hook. (Not yet implemented)
  116.       PM_CENTERSCREEN   = TAG_USER + 094 , -> Center menu on the screen
  117.       PM_USELMB         = TAG_USER + 095 , -> Left mouse button should be used to select an item
  118.                                            -> (right button selects multiple items)
  119.       PM_DRIPENSONLY    = TAG_USER + 096   -> Only use the screens DRI pens, revert to system images if necessary.
  120.                                            -> Use with care as it overrides the users prefs !
  121.  
  122.  
  123. -> Tags passed to Item
  124.  
  125. CONST PM_TITLE                = TAG_USER + 020 , -> Item title
  126.       PM_USERDATA             = TAG_USER + 021 , -> Anything, returned by OpenPopupMenu when this item is selected
  127.       PM_ID                   = TAG_USER + 022 , -> ID number, if you want to access this item later
  128.       PM_SUB                  = TAG_USER + 023 , -> Pointer to submenu list (from MakeMenu)
  129.       PM_FLAGS                = TAG_USER + 024 , -> For internal use
  130.       PM_NOSELECT             = TAG_USER + 025 , -> Make the item unselectable
  131.       PM_FILLPEN              = TAG_USER + 026 , -> Make the item appear in FILLPEN
  132.       PM_CHECKIT              = TAG_USER + 027 , -> Leave space for a checkmark
  133.       PM_CHECKED              = TAG_USER + 028 , -> Make this item is checked
  134.       PM_ITALIC               = TAG_USER + 029 , -> Italic text
  135.       PM_BOLD                 = TAG_USER + 030 , -> Bold text
  136.       PM_UNDERLINED           = TAG_USER + 031 , -> Underlined text
  137.       PM_TITLEBAR             = TAG_USER + 032 , -> Horizontal separator bar
  138.       PM_WIDETITLEBAR         = TAG_USER + 033 , -> Same as above, but full width
  139.       PM_SHADOWPEN            = TAG_USER + 034 , -> Draw text in SHADOWPEN
  140.       PM_SHINEPEN             = TAG_USER + 035 , -> Draw text in SHINEPEN
  141.       PM_CENTER               = TAG_USER + 036 , -> Center the text of this item
  142.       PM_EXCLUDE              = TAG_USER + 037 , -> Items to unselect (or select) when this gets selected
  143.       PM_DISABLED             = TAG_USER + 038 , -> Disable an item
  144.       PM_IMAGESELECTED        = TAG_USER + 039 , -> Image when selected, PM_Title will be render on top of the image
  145.       PM_IMAGEUNSELECTED      = TAG_USER + 040 , -> Image when unselected
  146.       PM_ICONSELECTED         = TAG_USER + 041 , -> Icon when selected
  147.       PM_ICONUNSELECTED       = TAG_USER + 042 , -> Icon when unselected
  148.       PM_OBJECT               = TAG_USER + 043 , -> BOOPSI object
  149.       PM_AUTOSTORE            = TAG_USER + 044 , -> Pointer to BOOL reflecting the current state of the item
  150.       PM_TEXTPEN              = TAG_USER + 045 , -> Pen number for text colour of this item, if you want to allocate a pen yourself
  151.       PM_USERDATASTRING       = TAG_USER + 046 , -> Allocates memory and copies the string.
  152.       PM_COMMKEY              = TAG_USER + 047 , -> Keyboard shortcut for this item.
  153.       PM_SHADOWED             = TAG_USER + 048 , -> Gives the text a shadow
  154.       PM_TITLEID              = TAG_USER + 049 , -> Locale string ID (not yet implemented)
  155.       PM_COLOURBOX            = TAG_USER + 060 , -> Filled rectangle
  156.       PM_SUBCONSTRUCT         = TAG_USER + 061 , -> Constructor hook for submenus. Called before the menu is opened.
  157.       PM_SUBDESTRUCT          = TAG_USER + 062 , -> Destructor hook for submenus. Called after the menu has been closed.
  158.       PM_HIDDEN               = TAG_USER + 063 , -> This item is not to be drawn
  159.       PM_LAYOUTMODE           = TAG_USER + 064 , -> Layout method ( PML_HORIZONTAL | PML_VERTICAL )
  160.       PM_MEMBERS              = TAG_USER + 065   -> Members for this group
  161.  
  162. -> Tags passed to MakeMenu
  163. CONST PM_ITEM    = TAG_USER + 050 , -> Item pointer from MakeItem
  164.       PM_DUMMY   = TAG_USER + 051   -> Sometimes very useful
  165.  
  166.  
  167. -> Tags passed to MakeIDList
  168. CONST PM_EXCLUDEID = TAG_USER + 055 , -> ID number of menu to deselect when this gets selected
  169.       PM_INCLUDEID = TAG_USER + 056 , -> ID number of menu to select when this gets selected
  170.       PM_REFLECTID = TAG_USER + 057 , -> ID number of menu that should reflect the state of this one
  171.       PM_INVERSEID = TAG_USER + 058   -> ID number of menu to inverse reflect the state of this one
  172.  
  173.  
  174. -> Tags for Pm_InsertMenuItemA()
  175. CONST PM_INSERT_BEFORE    = TAG_USER + 200 , -> (N/A) Insert before the item pointed to by the following argument (NOT AVAILABLE IN THE CURRENT VERSION)
  176.       PM_INSERT_BEFOREID  = TAG_USER + 201 , -> (N/A) Insert before the first item with ID equal to the argument (NOT AVAILABLE IN THE CURRENT VERSION)
  177.       PM_INSERT_AFTER     = TAG_USER + 202 , -> Insert after the item pointed to by the following argument
  178.       PM_INSERT_AFTERID   = TAG_USER + 203 , -> Insert after the first item with ID equal to the argument
  179.       PM_INSERT_LAST      = TAG_USER + 205 , -> Insert after the last item
  180.       PM_INSERT_FIRST     = TAG_USER + 209 , -> Insert after the first item (which is usually invisible)
  181.       PM_INSERTSUB_FIRST  = TAG_USER + 206 , -> Insert before the first item in the submenu pointed to by the argument
  182.       PM_INSERTSUB_LAST   = TAG_USER + 207 , -> Insert at the and of a submenu
  183.       PM_INSERTSUB_SORTED = TAG_USER + 208 , -> (N/A)
  184.       PM_INSERT_ITEM      = TAG_USER + 210   -> Item to insert, may be repeated for several items
  185.  
  186.  
  187. -> Layout methods
  188. CONST PML_NONE            = 0     ,  -> Normal item
  189.       PML_HORIZONTAL      = 1     ,  -> Horizontal group
  190.       PML_VERTICAL        = 2     ,  -> Vertical group
  191.       PML_TABLE           = 3     ,  -> Table group
  192.       PML_DEFAULT         = 255      -> Don't use
  193.  
  194.  
  195. CONST PMERR = -5
  196.  
  197. ->»»>
  198.  
  199.  
  200. /* -- ----------------------------------------------------------------- -- *
  201.  * --                            Structures                             -- *
  202.  * -- ----------------------------------------------------------------- -- */
  203.  
  204. ->»» OBJECT popupmenubase
  205. OBJECT popupmenubase OF lib
  206.   pmb_SegList         : LONG
  207.   pmb_Flags           : LONG
  208.   pmb_ExecBase        : PTR TO lib      -> These library
  209.   pmb_UtilityBase     : PTR TO lib      -> pointers are
  210.   pmb_IntuitionBase   : PTR TO lib      -> valid as long
  211.   pmb_GfxBase         : PTR TO lib      -> as pm lib 
  212.   pmb_DOSBase         : PTR TO lib      -> is open.      
  213.   pmb_NewPrefs        : INT             -> (BOOL) Reload prefs.
  214.   pmb_CxBase          : PTR TO lib      -> commodities.   
  215. ENDOBJECT
  216.  
  217.  
  218. -> PopupMenu structure
  219. ->
  220. -> WARNING!
  221. -> This structure may change in future versions.
  222. -> I'm about to change EVERYTHING below "UserData" in
  223. -> this structure to save some memory for items that do not
  224. -> require all that stuff.
  225. -> I might also move "Title", so the ONLY fields in this
  226. -> structure that you can READ safely is "ID" and "UserData".
  227. -> You can also write to "UserData" - this is entierly your
  228. -> own field and is not used by any of the library functions.
  229. ->
  230.  
  231. ->»» OBJECT popupmenu
  232. OBJECT popupmenu
  233.   ppm_Next           : PTR TO popupmenu
  234.   ppm_Sub            : PTR TO popupmenu
  235.  
  236.   -> The following component is a union:
  237.   ->
  238.   ->    .ppm_TileID  : LONG
  239.   -> or .ppm_Boopsi  : PTR TO object
  240.   ->
  241.   ppm_Title          : PTR TO CHAR       -> Title
  242.  
  243.   ppm_Flags          : LONG              -> Flags
  244.   ppm_ID             : LONG              -> Item ID
  245.   ppm_UserData       : LONG              -> UserData
  246.  
  247. PRIVATE
  248.   ppm_Left           : INT               -> Position and dimensions of the item
  249.   ppm_Top            : INT
  250.   ppm_Width          : INT
  251.   ppm_Height         : INT
  252. PUBLIC
  253.  
  254.   -> NOTE:
  255.   -> The fields below exist only when they are required !
  256.   ppm_ExtFlags       : INT
  257.   ppm_Layout         : CHAR
  258.   ppm_ColBox         : CHAR
  259.   ppm_Exclude        : PTR TO LONG     -> Exclude/Included/Reflected items
  260.   ppm_AutoSetPtr     : PTR TO INT      -> Ptr to BOOL containing current state
  261.   ppm_UnSelected     : PTR TO image    -> Unselected image or icon
  262.   ppm_Selected       : PTR TO image    -> Selected image or icon
  263.   ppm_Mask[2]        : ARRAY OF CHAR   -> Image/Icon blit masks
  264.   pmm_CommKey        : CHAR            -> Command Key
  265.   ppm_Weight         : CHAR            -> Weight
  266.   ppm_TextPen        : LONG            -> Pen number for item's text
  267.   ppm_SubConstruct   : PTR TO hook     -> SubMenu Constructor hook
  268.   ppm_SubDestruct    : PTR TO hook     -> SubMenu Destructor hook
  269. ENDOBJECT
  270. ->»»>
  271.